package com.star.security.context;

import com.star.security.authentication.Authentication;

/**
 * 本地线程令牌上下文持有者策略
 *
 * @author yangzj
 */
public class ThreadLocalTokenContextHolderStrategy implements TokenContextHolderStrategy {

    private static final ThreadLocal<Authentication> contextHolder = new ThreadLocal<>();

    @Override
    public void clearContext() {
        contextHolder.remove();
    }

    @Override
    public Authentication getContext() {
        return contextHolder.get();
    }

    @Override
    public void setContext(Authentication context) {
        contextHolder.set(context);
    }

}
